import { saveMonitorhcDispose } from '@/services/api/api-monitor-article';
import { DrawerForm, ProFormRadio, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { Button, Form, message } from 'antd';

interface ModalResolveProps {
  id: string;
  onRefurbish: () => void;
}
const ModalResolve: React.FC<ModalResolveProps> = ({ id, onRefurbish }) => {
  const [form] = Form.useForm<{ name: string; company: string }>();

  return (
    <DrawerForm<{
      mark: string;
    }>
      title="处置"
      form={form}
      trigger={<Button type="primary">处置</Button>}
      autoFocusFirstInput
      drawerProps={{
        destroyOnClose: true,
        width: '100%',
      }}
      submitTimeout={2000}
      onFinish={async (values) => {
        const res = await saveMonitorhcDispose({
          includeRecordId: id,
          scheme: values.scheme,
          content: values.mark,
        });
        if (res.code === 0) {
          message.success('处置成功');
          onRefurbish()
        } else {
          message.error('处置失败');
        }
        // 不返回不会关闭弹框
        return true;
      }}
    >
      <ProFormRadio.Group
        label="处置类型"
        name="scheme"
        required={true}
        options={[
          {
            label: '不需要处理',
            value: 1,
          },
          {
            label: '下架不再发稿',
            value: 2,
          },
          {
            label: '下架修改重新发稿',
            value: 3,
          },
          {
            label: '其他方案',
            value: 4,
          },
        ]}
      />

      <ProFormTextArea name="mark" label="处置备注" placeholder="请输入处置备注" />
    </DrawerForm>
  );
};
export default ModalResolve;
